﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Modules_Module_LimitManager : System.Web.UI.UserControl
{
    private void Bind()
    {
        MysqlHelp LimitMgr = new MysqlHelp();
        string conn = "select * from syslimit where enable=1";
        this.GridView_LM.DataSource = LimitMgr.GetDatabysql(conn);
        this.GridView_LM.DataKeyNames = new System.String[] { "id" };
        this.GridView_LM.DataBind();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Bind();
        }
    }
    protected void GridView_LM_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {

    }
    protected void GridView_LM_RowEditing(object sender, GridViewEditEventArgs e)
    {
        this.GridView_LM.EditIndex = e.NewEditIndex;
        Bind();
        ((CheckBox)(GridView_LM.Rows[e.NewEditIndex].FindControl("UserManagerLM"))).Enabled = true;
        ((CheckBox)(GridView_LM.Rows[e.NewEditIndex].FindControl("BBSManagerLM"))).Enabled = true;
        ((CheckBox)(GridView_LM.Rows[e.NewEditIndex].FindControl("NewsManagerLM"))).Enabled = true;
        ((CheckBox)(GridView_LM.Rows[e.NewEditIndex].FindControl("SourceManagerLM"))).Enabled = true;
        ((CheckBox)(GridView_LM.Rows[e.NewEditIndex].FindControl("UploadManagerLM"))).Enabled = true;
        ((CheckBox)(GridView_LM.Rows[e.NewEditIndex].FindControl("DownloadManagerLM"))).Enabled = true;
        ((CheckBox)(GridView_LM.Rows[e.NewEditIndex].FindControl("SCManagerLM"))).Enabled = true;
    }
    protected void GridView_LM_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        MysqlHelp Adupdate = new MysqlHelp();
        string sqlconn = "update news set enable=0 where id='" + GridView_LM.DataKeys[e.RowIndex].Value.ToString() + "'";
        int back = Adupdate.Runsql(sqlconn);
        if (back != -1)
        {
            Response.Write("<script>alert('新闻删除成功！')</script>");
            Bind();
        }
        else
        {
            Response.Write("<script>alert('新闻删除失败！');history.goback(-1);</script>");
        }
        this.GridView_LM.DataBind();
    }
    protected void GridView_LM_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        GridView_LM.EditIndex = -1;
        Bind();
    }
}
